%skeleton "lalr1.cc"
%require  "2.5"
%debug 
%defines 
%define namespace "MC"
%define parser_class_name "MC_Parser"

%code requires{
   namespace MC {
      class MC_Driver;
      class MC_Scanner;
   }
}

%lex-param   { MC_Scanner  &scanner  }
%parse-param { MC_Scanner  &scanner  }

%lex-param   { MC_Driver  &driver  }
%parse-param { MC_Driver  &driver  }

%code{
   #include <iostream>
   #include <cstdlib>
   #include <fstream>
   #include <stdio.h>
   #include <sstream>
   #include <strstream>
   /* include for all driver functions */
   #include "mc_driver.hpp"
  

   static int yylex(MC::MC_Parser::semantic_type *yylval,
                    MC::MC_Scanner  &scanner,
                    MC::MC_Driver   &driver);
   
}
					

/* token types */
%union {
   char * sval;
   int   ival;
   float rval;
}

%token        END    0
%token <rval> T_REAL
%token <ival> T_INT
%token <sval> T_STRING
%token        T_LT
%token        T_LE
%token        T_GT
%token        T_GE
%token        T_EQ
%token        T_NE

%type <sval> list_option
%type <sval> list
%type <sval> object

	  %%

list_option  : END
 			 | list END
			 ;

list         : object
			 | list object
             ;
			 
object		 : T_STRING{
				std::cout<<"this is a string:"<<$1<<std::endl;
			 }
			 | T_INT{
				std::cout<< "this is an int:"<<$1<<std::endl;
			 }	
			 | T_REAL{
				std::cout << "this is a float:"<<$1<<std::endl;
			 }
			 ;	


%%


void MC::MC_Parser::error( const MC::MC_Parser::location_type &l,
                           const std::string &err_message)
{
   std::cerr << "Error: " << err_message << "\n"; 
}



/* include for access to scanner.yylex */
#include "mc_scanner.hpp"
static int yylex(MC::MC_Parser::semantic_type *yylval,
                 MC::MC_Scanner  &scanner,
                 MC::MC_Driver   &driver)
{
   return( scanner.yylex(yylval) );
}

